package cn.wp.common.core.dao;

import cn.hutool.core.collection.CollectionUtil;

import java.util.Set;

/**
 * 乐观锁构建对象
 * Created by chenyb on 2020/01/16
 */
public class OLock {

    private String table;

    // 默认值 lock_version
    private String lockColumn = "lock_version";

    private Set<String> setColumns = CollectionUtil.newHashSet();

    private Set<String> conditions = CollectionUtil.newHashSet();

    public OLock table(String table){
        this.table = table;
        return this;
    }

    /**
     * 指定乐观锁列字段
     * @param lockColumn
     * @return
     */
    public OLock lockColumn(String lockColumn){
        this.lockColumn = lockColumn;
        return this;
    }

    public OLock set(String express){
        setColumns.add(express);
        return this;
    }

    public OLock and(String express){
        conditions.add(express);
        return this;
    }


    public String getTable() {
        return table;
    }

    public String getLockColumn() {
        return lockColumn;
    }

    public Set<String> getSetColumns() {
        return setColumns;
    }

    public Set<String> getConditions() {
        return conditions;
    }

}